package com.lijing.uniquePath;

/**
 * @Description TODO
 * @title: UniquePath01
 * @Author LiJing
 * @Date: 2021/4/610:23 上午
 * @Version 1.0
 */
public class UniquePath01 {
    public static void main(String[] args) {
        int m = 3;
        int n = 1;
        System.out.println(uniquePath(m,n));
    }

    public static int uniquePath(int m, int n){
        /*
         * @Date: 2021/4/6 10:24 上午
         * Step 1: 确定状态
         * methodCal[i][j]表示走到第i行j列的行走方式
         */
        int[][] methodCal = new int[m][n];

        /*
         * @Date: 2021/4/6 10:28 上午
         * Step 3: 使用状态转移方程进行计算
         */
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (i == 0 || j == 0){
                    methodCal[i][j] = 1;
                }else {
                    methodCal[i][j] = methodCal[i-1][j] + methodCal[i][j-1];
                }

            }
        }
        return methodCal[m-1][n-1];
    }
}
